﻿using AutoMapper;
using MediatR;
using S.EarTag.API.Application.MediatorCommand.BreedingWeighCommand;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Impl.EarTagRepository;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Application.MediatorCommandHandler.BreedingWeighCommandHandler
{
    //修改
    public class UpdateBreedingCommandHandler : IRequestHandler<UpdateBreedingCommand, bool>
    {
        private readonly IBreedingWeighRepository db;
        private readonly IMapper mapper;

        public UpdateBreedingCommandHandler(IBreedingWeighRepository db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }
        public async Task<bool> Handle(UpdateBreedingCommand request, CancellationToken cancellationToken)
        {
            return await db.UpdateBreeding(mapper.Map<BreedingWeigh>(request));
        }                 
    }
}
